﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace FunctionalProgramming.PatternMatching.CollectionMatchingRules
{
   internal class Empty<T> : ICollectionMatchingRule<T>
   {
      private readonly Action action;

      public Empty(Action action)
      {
         this.action = action;
      }

      public bool DoesCollectionMatch(IEnumerable<T> collection)
      {
         bool result = collection.Count() == 0;
         return result;
      }

      public void ExecuteWithCollection(IEnumerable<T> collection)
      {
         action();
      }
   }
}